package com.example.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<User> {
    
    @Select("SELECT * FROM user WHERE username = #{username}")
    @Results({
        @Result(property = "id", column = "id"),
        @Result(property = "username", column = "username"),
        @Result(property = "password", column = "password"),
        @Result(property = "email", column = "email"),
        @Result(property = "createdBy", column = "created_by"),
        @Result(property = "createdAt", column = "created_at"),
        @Result(property = "updatedBy", column = "updated_by"),
        @Result(property = "updatedAt", column = "updated_at", jdbcType = JdbcType.TIMESTAMP),
        @Result(property = "enabled", column = "enabled"),
        @Result(property = "accountNonLocked", column = "account_non_locked"),
        @Result(property = "accountNonExpired", column = "account_non_expired"),
        @Result(property = "credentialsNonExpired", column = "credentials_non_expired")
    })
    User findByUsername(String username);
}